<?php
/*
 * Created on 22.12.2005
 *
 */

class c_foreachHandler 
{

    function startElement (& $sender, $attrs)
    {
        if (!$attrs['value'])
        {
            die ("Attribute value is missing in out tag\n");
        }
        $var = substr($attrs['var'], 1, strlen($attrs['var'])-2);
        if (!preg_match('/\w+/', $var))
            die ("Attribute var must not contain EL code\n");
        $var = '$'.$var;
        $sender->appendCode('if (is_array('.$attrs['value'].')) foreach ('.$attrs['value']." as ".$var.") {\n");
    }
    
    function endElement (& $sender)
    {
        $sender->appendCode("}\n");
    }

}

?>
